<?php
/**
 * Created by lzl
 * Date: 2021 2021/9/14
 * Time: 13:29
 */
namespace App\Http\Controllers\Admin;

use App\Forms\UserForms;

class UsersController extends Controller
{

    /**
     * 会员列表
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed
     * @throws \App\Exceptions\RequestException
     */
    public function userList()
    {
        if($this->request->ajax()) {
            $rules = [
                'page'  => 'required',
                'limit' => 'required',
                'name'  => 'nullable',
                'level' => 'nullable'
            ];

            $this->validateInput($rules);

            return $this->showJsonLayui((new UserForms())->getUserList($this->validated));
        }

        return $this->view('user.user_list');
    }


    public function level()
    {
//        if($this->request->ajax()) {
//            $rules = [
//                'page'  => 'required',
//                'limit' => 'required',
//                'type'  => 'required'
//            ];
//
//            $this->validateInput($rules);
//
//            return $this->showJsonLayui((new UserForms())->getUserList($this->validated));
//        }
//
//        return $this->view('user.level');
    }


    /**
     * 用户余额记录
     * @param $uid
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed
     * @throws \App\Exceptions\RequestException
     */
    public function balanceLog($uid)
    {
        if($this->request->ajax()) {
            $rules = [
                'page'  => 'required',
                'limit' => 'required',
            ];

            $this->validateInput($rules);

            return $this->showJsonLayui((new UserForms())->getUserBalanceLog(
                array_merge($this->validated, compact('uid'))
            ));
        }

        return $this->view('user.balance', compact('uid'));
    }


    /**
     * @param $uid
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function detail($uid)
    {
        $userForms = new UserForms();

        $user = $userForms->getUserDetail($uid);

        return $this->view('user.detail', compact('user'));
    }



}